package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.pojo.MemberSetmealDto;
import com.itheima.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {


    @Autowired
    private OrderService orderService;

    //根据预约id查询预约信息
    @PostMapping("/findById")
    public Result findById(@RequestParam Integer id) {

        log.info("根据预约id查询预约信息 {}" , id);
        return  new Result(true, MessageConstant.QUERY_ORDER_SUCCESS, orderService.findById(id));
    }

    // 体检预约
    @PostMapping("/submitOrder")
    public Result submit(@RequestBody MemberSetmealDto memberSetmealDto) throws Exception {
        log.info("体检预约{}" ,memberSetmealDto);



        return new Result(true, MessageConstant.ORDER_SUCCESS ,orderService.submit(memberSetmealDto) );
    }

}
